﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

namespace UpdateDatabase
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlConnectionString = Utils.Setting.ConnectionString;

                SqlConnection conn = new SqlConnection(sqlConnectionString);
                Server server = new Server(new ServerConnection(conn));

                server.ConnectionContext.ExecuteNonQuery(txtSql.Text);
                MessageBox.Show("Cập nhật thành công!");
                conn.Close();
            }
            catch
            {
                MessageBox.Show("Cập nhật lỗi!");
            }
            
        }
    }
}
